package nccloud.web.hrjx.pubinfo.datacoll.action;

import java.util.ArrayList;
import java.util.Map;

import nc.impl.pubapp.pattern.database.IDQueryBuilder;
import nc.vo.hrjx.DataCollVO;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.container.SessionContext;
import nccloud.framework.web.ui.pattern.grid.Grid;
import nccloud.framework.web.ui.pattern.grid.GridOperator;
import nccloud.itf.bd.datacoll.IDatacollQryService;
import nccloud.web.action.NCCAction;

/***************************************************************
* 鍥藉鍦板尯鍒嗛〉鏌ヨ
* @author tangcht
* @version nccloud1.0
* @since 2018-9-30
* @see
***************************************************************/
public class DatacollQueryPageGridByPksAction extends NCCAction {

@Override
public <T> Object execute(IRequest request, T para) throws Exception {
    Grid grid = null;
    Map<String, Object> paras = (Map<String, Object>) para;
    
    Map<String, Object> pageInfo = (Map<String, Object>) paras.get("pageInfo");
    double pageIndexd = (Double) pageInfo.get("pageIndex");
    int pageIndex = (int) pageIndexd;
    int pageSize = Integer.parseInt((String)pageInfo.get("pageSize"));
    
    Map<String, Object> querycondition = (Map<String, Object>) paras.get("querycondition");
    
    String sessionid = SessionContext.getInstance().getSessionid();
    IDatacollQryService qryService = ServiceLocator.find(IDatacollQryService.class);
    Map<String, Object> resmap = qryService.queryByPage(sessionid, querycondition, pageSize, pageIndex);
	DataCollVO[] vos = (DataCollVO[]) resmap.get("vos");
//	int totalPages = (int) resmap.get("totalPages");
//	int totalNum = (int) resmap.get("totalNum");
    
    GridOperator opr = new GridOperator(DatacollConsts.pagecode);
    grid = opr.toGrid(vos);
    return grid;
    }

    }


